//
//  ViewController.swift
//  Swift1
//
//  Created by CrateMac0 on 16/3/19.
//  Copyright © 2016年 Users. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    
    private var edit: EditViewController?
    
    @IBOutlet weak var ageLabel: UILabel!
    @IBOutlet weak var nameLabel: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    
    @IBAction func click(sender: AnyObject) {
        let sb = UIStoryboard(name: "Main", bundle: nil)
        let editVC = sb.instantiateViewControllerWithIdentifier("EditViewController") as!EditViewController
        editVC.name = self.nameLabel.text
        editVC.age = self.ageLabel.text
        editVC.callback = {[weak self](name: String, age: String)->() in
            //print("我在ViewController里面")
            //print("名字:\(name), 年龄:\(age)")
            self?.nameLabel.text = name
            self?.ageLabel.text = age
        }
        edit = editVC
        navigationController?.pushViewController(editVC, animated:true)
        
    }
    
    deinit {
        print("ViewController")
    }
    
    //MARK: - 懒加载
    lazy var b:Person = {
        let a = Person(name: "cy", age: "15")
        return a
    }()
    
    
    
    
    
    
    
    
//    MARK: - 懒加载
     lazy var person: Person = Person(name: "萝莉", age:"10")
    private lazy var person2: Person = {
        let p = Person(name: "归属里", age:"30")
        print("p:\(p)")
        return p
    }()
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        print("person2.name: \(person2.name)")
        print("person.name: \(person.name)")
    }

}

